<%@ LANGUAGE = VBScript CodePage = 65001%>
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：Create.asp
'= 摘    要：执行安装文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-10-25
'====================================================================

Response.Charset="UTF-8"

Dim ConnStr
On Error Resume Next
Response.Clear

Response.write "<script language=""JavaScript"">" & VBCrlf & "parent.document.all.viewcode.innerHtml='';" & VBCrlf
Set Conn = server.createobject("ADODB.Connection")

Select Case LCase(Request("Type"))
Case "data"
	Err.Clear
	If request("datatype")="0" Then 
		ConnStr="Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(Request("DataName"))
		Conn.Open ConnStr
	Else
		ConnStr="Provider=Sqloledb;server="& Request("DataHost") &";uid="& Request("DataUser") &";pwd="& Request("DataPass") & ";database="& Request("DataName")
		Conn.Open ConnStr
	End If
	
	If Err.Number <> 0 Then
		Response.Write "parent.document.all.viewcode.innerText='您的数据驱动存在问题,或者您设定的条件不足以连接指定的数据服务器"&Request("DataName")&"';" & VBcrlf
		Response.write ("</script>")
		Response.End
	End If
	Conn.Close

	Dim Content
	If request("datatype")<>"0" Then 
		Content = "<" & CHR(37) & VBCrlf
		Content = Content & "Dim ConnStr" & VBCrlf
		Content = Content & "ConnStr = ""Provider=Sqloledb;server="& Request("DataHost") &";uid="& Request("DataUser") &";pwd="& Request("DataPass") &";database="& Request("DataName") &"""" & VBCrlf
		Content = Content & "Const sCacheName=""" & Request("key") & """" & VBCrlf
		Content = Content & "Const SystemFolder=""" & Request("folder") & """" & VBCrlf
		Content = Content & CHR(37) & ">" & VBCrlf
	Else
		Content = "<" & CHR(37) & VBCrlf
		Content = Content & "Dim ConnStr" & VBCrlf
		Content = Content & "Dim DataBaseFilePath" & VBCrlf
		Content = Content & "DataBaseFilePath=""" &Request("DataName") & """" & VBCrlf
		Content = Content & "ConnStr=""Provider = Microsoft.Jet.OLEDB.4.0;Data Source ="""
		Content = Content & " & Server.MapPath(DataBaseFilePath)"& VBCrlf
		Content = Content & "Const sCacheName=""" & Request("key") & """" & VBCrlf
		Content = Content & "Const SystemFolder=""" & Request("folder") & """" & VBCrlf
		Content = Content & CHR(37) & ">" & VBCrlf
	End If
	
	Call WriteFile(Content,1,server.MapPath ("Connection.asp"))
	
	Response.Write "parent.document.all.viewcode.innerHTML='配置文件已被创建.<BR>';" & VBcrlf
	Response.Flush

	Conn.Close
	Set Conn = Nothing
End Select
Response.write ("parent.document.all.N.disabled=false; "& VBCrlf &"</script>")

Sub WriteFile(Content,S,Path)
	Err.Clear
	Set MyFile = Server.CreateObject("ADOD" & "B.S" & "TREAM")
	With MyFile
		.Open
		.Charset = "utf-8"
		.WriteText Content
		.SaveToFile Path,2
		.Close
	End With
	If Err.Number <> 0 Then Response.Write ("parent.document.all.viewcode.innerHTML='因为您的服务器FSO权限设置可能有点问题,配置文件未被写入,请自行将以下内容写入系统根目录目录的[Connection.asp]文件:<BR><font color=#666666>"& Content &"</font><BR>';" & VBcrlf)
End Sub
%>